package Ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Add implements Ioperate{
    @Override
    public void operate(BookList bookList) {
        int count = bookList.getCount();
        int curSize = bookList.getCurSize();
        if(count == curSize){
            System.out.println("书架已满，无法再放入别的图书.......");
            return;
        }

        System.out.println("请输入你要增加的书名:");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        System.out.println("请输入作者名字");
        String author = scan.nextLine();
        System.out.println("请输入图书类型：");
        String type = scan.nextLine();
        System.out.println("请输入图书价格：");
        double price = scan.nextDouble();

        Book newBook = new Book(name,author,type,price);
        bookList.setBooks(curSize,newBook);
        bookList.setCurSize(curSize + 1);
    }
}
